import {gatewayExecuteWayOptions} from '@/components/flow/typs/flow.js';

export default {
  draw(cfg, group) {
    let classNames = [
      'h-flow-gate-way',
      'h-flow-node',
      'h-flow-gate-way-' + cfg.gatewayType,
      'h-flow-gate-way-' + cfg.executeWay
    ];
    if (cfg.passed && (cfg.gatewayType !== 'start' || cfg.executeWay !== 'exclusive')) {
      classNames.push('h-flow-node-history-passed')
    } else if (cfg.passed) {
      classNames.push('h-flow-gate-way-history-passed')
    }

    return group.addShape('dom', {
      attrs: {
        width: 30,
        height: 90,
        html: `<div class="h-flow-gate-way-wrapper"><div title="${this.getGateWayTitle(cfg)}" data-role="gateway" data-id="${cfg.id}" class="${classNames.join(" ")}"/>
               </div>`,
        name: 'gateway',
      },
    });
  },

  getGateWayTitle(cfg) {
    return (gatewayExecuteWayOptions.find(o => o.value === cfg.executeWay) || {label: ''}).label;
  },

  getAnchorPoints(cfg) {
    return [
      [0.5, 0.5],
      [0.5, 0.5],
    ];
  }
};
